package zld369504.tw.m_team;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ProgressBar;

import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso;

import uk.co.senab.photoview.PhotoView;
import uk.co.senab.photoview.PhotoViewAttacher;

/**
 * Created by zouzheming on 2016/11/30 16:29
 * 邮箱：920108874@qq.com
 * 手机：18352533507
 */
public class ShowImageActivity extends AppCompatActivity {
    private PhotoView mImageView;
    private ProgressBar mProgressBar;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_image);
        mImageView = (PhotoView) findViewById(R.id.iv_photo);
        mProgressBar = (ProgressBar) findViewById(R.id.photoview_progressbar);
        Intent intent = getIntent();
        if (intent != null) {
            String url = intent.getStringExtra("URL");
            Picasso.with(this).load(url).error(R.drawable.load_error).into(mImageView, new Callback() {
                @Override
                public void onSuccess() {
                    mProgressBar.setVisibility(View.GONE);
                }

                @Override
                public void onError() {
                    mProgressBar.setVisibility(View.GONE);
                }
            });
        }
        mImageView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
            @Override
            public void onPhotoTap(View view, float x, float y) {
                finish();
            }

            @Override
            public void onOutsidePhotoTap() {

            }
        });
    }
}
